package com.zmn.brs.common.enums;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * 类描述：阈值类型枚举
 *
 * @author chongw
 * @since 2021/07/12 10:47
 */
public enum ThresholdTypeEnum {

    /**
     *
     */
    ROLE(1, "角色" ),
    TIME(2, "时间" ),
    CITY(3, "城市" ),
    FREQUENCY(4, "频次" ),
    COMMON(5, "公共阈值" ),
    ;

    /**
     * 类型
     */
    private final Integer typeId;

    /**
     * 类型名
     */
    private final String typeName;


    ThresholdTypeEnum(Integer typeId, String typeName) {

        this.typeId = typeId;
        this.typeName = typeName;
    }

    public Integer getTypeId() {

        return typeId;
    }

    public String getTypeName() {

        return typeName;
    }


    public static ThresholdTypeEnum getEventTypeEnum(Integer typeId) {

        Optional<ThresholdTypeEnum> optional = Stream.of(ThresholdTypeEnum.values()).filter(e -> e.getTypeId().equals(typeId)).findFirst();
        return optional.orElse(null);
    }
}
